package chapter6;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 回文整数
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc6_3 {
	
	public static int reverse(int number) {
		int reverse=0;
		
		while(number>0) {
			
			reverse=reverse*10+number%10;
			number/=10;
			
		}
		
		//下面这种方法也可以
//		for(int i=number.length()-1;i>=0;i--)
//            reverse+=number.charAt(i);
		return reverse;
	}
	
	public static boolean isPalidrome(int number) {
		
		return (reverse(number)==number)?true:false ;
		
	}
	
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter an integer:  ");
		int n=input.nextInt();
		
		if(isPalidrome(n)) {
			System.out.print(n+" is a Palidrome.");
		}else {
			System.out.print(n+" is not  a Palidrome.");
		}
		
	}

}
